package com.base.component.aws.sqs;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.amazonaws.auth.AWSStaticCredentialsProvider;
import com.amazonaws.auth.BasicAWSCredentials;
import com.amazonaws.services.sqs.AmazonSQSAsync;
import com.amazonaws.services.sqs.AmazonSQSAsyncClientBuilder;


@Configuration
public class MqConfiguration {

    @Value("${aws.sqs.accessKey}")
    private String accessKey;
    @Value("${aws.sqs.secretKey}")
    private String secretKey;
    @Value("${aws.sqs.region}")
    private String region;

    @Bean
    public AmazonSQSAsync amazonSQSAsyncClient() {
        BasicAWSCredentials basicAWSCredentials = new BasicAWSCredentials(accessKey, secretKey);
        return AmazonSQSAsyncClientBuilder.standard()
                .withCredentials(new AWSStaticCredentialsProvider(basicAWSCredentials))
                .withRegion(region)
                .build();
    }
    
}
